You are here: Building the Model: Advanced Elements > Subroutines > Subroutine Example > Subroutine Logic
The final step in defining the subroutine is to specify the logic to be processed when the subroutine is called. In this example, the logic should include a processing time, a procedure to write the values of the attributes to a file, and a routing decision based on the values of the two attributes. The logic window is accessed by clicking on the Logic heading button.
The first line of the logic calculates the order time as a function of the Quantity and Quality attributes passed as parameters. These parameters are used as arguments in two user defined functions, ProcTime() and QualFactor(). Function ProcTime() returns a time value based on the number of copies in the order, while function QualFactor() returns a scale factor depending upon the quality level desired. Operation time is determined by simply multiplying the process time by the scale factor.
Once the order time has been determined, this value is written to the file Report.Dat. Included with the operation time is the job number and the location at which the job was processed.
The last line of the logic returns the order time value to the processing logic.